﻿@{
    ViewBag.Title = "MemberEdit";
    Layout = "~/Views/Shared/_LayoutMember.cshtml";
    var user = Session["LoginUser"] as Domain.Model.User;
}
@model Domain.Model.UserBank

@section HeadScript
{
    <link href="~/Content/window/window.css" rel="stylesheet" />
    <script src="~/Content/window/window.js"></script>
    <link href="~/Content/validBox/validBox.css" rel="stylesheet" />
    <script src="~/Content/validBox/validBox.js"></script>
}
<form class="form-horizontal">
    <div class="fr2 green fs-25 Tbrline">信息安全->银行资料</div>


    <div class="fr2">


        <div class="control-group">
            <label class="control-label" for="Name">会员编号/昵称</label>
            <div class="controls">
                @Html.TextBox("No", user.Account + "/" + user.NickName, new { @Readonly="Readonly"})
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" for="Name">银行名称</label>
            <div class="controls">
                @Html.DropDownListFor(i=>i.Bank,new SelectList(Model.Bank.GetNameDisplays(),"key","value"))
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" for="Name">账号</label>
            <div class="controls">
                @Html.TextBoxFor(item => item.Account,Html.ValidFor(i=>i.Account))
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" for="Name">开户行地址</label>
            <div class="controls">
                @Html.TextBoxFor(item => item.Address,Html.ValidFor(i=>i.Address))
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" for="Name">开户名称</label>
            <div class="controls">
                @Html.TextBoxFor(i=>i.UserName,Html.ValidFor(i=>i.UserName))
            </div>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label"></label>
        <div class="controls">
            <input type="button" value="保    存" class="sbtn" onclick="saveForm()" />
        </div>
    </div>
</form>

@section Script
{
    <script type="text/javascript">
        function saveForm() {
            $("form").validBox(function (r) {
                if (!r) return;
                $.post("/Member/BankInfo/", $("form").serialize(), function (data) {
                    if (data.state) {
                        window.messageBox("提示", "保存成功！");
                    }
                    else {
                        window.messageBox("提示", data.value);
                    }
                });
            })
        }

        $(function () {
            $("#Bank").change(function () {
                
                $.post("/member/ChangeBank", $("form").serialize(), function (data) {
                    if (data.state) {
                        $("#Account").val(data.Account);
                        $("#Address").val(data.Address);
                        $("#UserName").val(data.UserName);
                    }
                    else {
                        $("#Account").val("");
                        $("#Address").val("");
                        $("#UserName").val("");
                    }
                });
            });
        });
    </script>
}
